<template>
    <div>
        <tableList
            :apis="apis"
            :searchItems="searchItems"
            :headItems="headItems"
            :actItems="actItems"
            :formWidth="formWidth"
            :formItems="formItems"
            @actButEvent="actButEvent"
        ></tableList>
    </div>
</template>

<script>
    export default {
        name: "discern-list",
        data () {
            return {
                apis: {
                    list: {
                        url: this.$api.V2X_OBJINFOS_GET,
                        params: {
                            with: 'locations;lidars;objTypes',
                            sortedBy: 'desc',
                            orderBy: 'id'
                        }
                    },
                },
                searchItems: [
                    {
                        type: "selectGroup",
                        key: 'lidar_id',
                        label: this.$t('page.discern.list.lidar_id.name'),
                        placeholder: this.$t('page.discern.list.lidar_id.placeholder'),
                        options: JSON.parse(sessionStorage.getItem('location-info'))
                    },
                    {
                        type: "select",
                        key: 'obj_type',
                        label: this.$t('page.discern.list.obj_type.name'),
                        placeholder: this.$t('page.discern.list.obj_type.placeholder'),
                        options: JSON.parse(sessionStorage.getItem('objType-info'))
                    },
                    {
                        type: "daterange",
                        key: "date",
                        splaceholder: "",
                        eplaceholder: ""
                    }
                ],
                headItems: [
                    { key: 'lidars.name', label: this.$t('page.discern.list.headitems.name') },
                    { key: 'obj_id', label: this.$t('page.discern.list.headitems.car_id') },
                    { key: 'obj_types.obj_name_cn', label: this.$t('page.discern.list.headitems.obj_types') },
                    { key: 'length', label: this.$t('page.discern.list.headitems.length') },
                    { key: 'width', label: this.$t('page.discern.list.headitems.width') },
                    { key: 'height', label: this.$t('page.discern.list.headitems.height') },
                    { key: 'pos_x', label: this.$t('page.discern.list.headitems.pos_x') },
                    { key: 'pos_y', label: this.$t('page.discern.list.headitems.pos_y') },
                    { key: 'speed', label: this.$t('page.discern.list.headitems.speed') },
                    { key: 'locations.location_name', label: this.$t('page.discern.list.headitems.locations') },
                    { key: 'origentation', label: this.$t('page.discern.list.headitems.origentation') },
                    { key: 'create_time', label: this.$t('public.form.created_at'), type: 'datetime' },
                ],
                actItems: [],
                formWidth: '500',
                formItems: [
                    {
                        key: "name",
                        label: "昵称",
                    },
                    {
                        key: "tel",
                        label: "手机号",
                        type: 'phone',
                        rule: ["NotBlank"]
                    },
                    {
                        key: "email",
                        label: "邮箱",
                        disabled: true,
                        type: 'email',
                        rule: ["NotBlank", 'Email']
                    },
                    {
                        key: "status",
                        label: "状态",
                        type: "radio",
                        options: [
                            { key: "禁用", value: 0 },
                            { key: "启用", value: 1 }
                        ],
                    },
                    {
                        key: "password",
                        label: "密码"
                    },
                    {
                        key: "password_confirmation",
                        label: "确认密码"
                    }
                ]
            }
        },
        methods: {
            actButEvent(e) {
                this[e.eventName](e.val);
            },
            detailAct(e) {
                this.actStatus = e.status;
                this.title = e.time;
                this.id = e.id;
                this.apisAddDeduction.list.params.id = e.id;
                this.dialogDetailActVisible = true;
                this.formLoading = true;
                this.detailHeader();
                this.apisDetailAct.list.params.id = e.id;
                this.apisDetailAct.export.params.id = e.id;
                this.apisDetailAct.total.params.id = e.id;
            },
        }
    }
</script>

<style scoped>

</style>
